package com.dms.modules.product.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

/**
 * 商品数据传输对象
 */
@Data
@ApiModel(value = "商品数据传输对象", description = "用于创建和更新商品的数据传输对象")
public class ProductDTO {

    @ApiModelProperty("商品ID，更新时必填")
    private Long id;

    @ApiModelProperty(value = "店铺ID（只读字段，由系统根据当前登录用户自动设置）", readOnly = true)
    private Long merchantId;

    @ApiModelProperty("商品分类ID")
    @NotNull(message = "商品分类不能为空", groups = Create.class)
    private Long categoryId;

    @ApiModelProperty("商品名称")
    @NotBlank(message = "商品名称不能为空")
    private String name;

    @ApiModelProperty("商品副标题")
    private String subtitle;

    @ApiModelProperty("商品主图")
    private String mainImage;

    @ApiModelProperty("商品子图列表")
    private List<String> subImages;

    @ApiModelProperty("商品详情")
    private String detail;

    @ApiModelProperty("商品状态（0-下架，1-上架）")
    private Integer status;

    @ApiModelProperty("原价")
    private BigDecimal originalPrice;

    @ApiModelProperty("是否推荐：0-否 1-是")
    private Integer isRecommend;

    @ApiModelProperty("是否新品：0-否 1-是")
    private Integer isNew;

    @ApiModelProperty("是否热销：0-否 1-是")
    private Integer isHot;

    @ApiModelProperty("商品规格JSON")
    private String specs;

    @ApiModelProperty("商品参数JSON")
    private String params;

    @ApiModelProperty("是否有规格：true-多规格商品，false-单规格商品")
    private Boolean hasSpecs = false;

    @ApiModelProperty("单规格商品价格（无规格商品必填）")
    @NotNull(message = "单规格商品必须设置价格", groups = SingleSpec.class)
    @Min(value = 0, message = "价格不能小于0")
    private BigDecimal singlePrice;

    @ApiModelProperty("单规格商品库存（无规格商品必填）")
    @NotNull(message = "单规格商品必须设置库存", groups = SingleSpec.class)
    @Min(value = 0, message = "库存不能小于0")
    private Integer singleStock;

    /**
     * 创建商品时的验证分组
     */
    public interface Create {
    }

    /**
     * 更新商品时的验证分组
     */
    public interface Update {
    }

    /**
     * 单规格商品的验证分组
     */
    public interface SingleSpec {
    }
} 